#include "fig_boss_beast.h"
#include "fighter.h"
#include "fig_bullet.h"
#include "fig_enemybullet_master.h"
#include "fig_player_craft.h"
#include "fig_sounds.h"
#include "fig_functions.h"
#include "fig_boss_attackmove_manager.h"
#include "fig_sounds.h"

#include "num/rand.h"
#include "math/facing.h"
#include "dd/dd_man.h"

FIGBossBeast::FIGBossBeast(FIGEnemyCraft::ENEMY_TYPES EnemyType) : 
								FIGEnemyBoss(
											EnemyType
											)
								
{
	//beast_arm_right
	 m_pArmLeft = m_Bone.GetBonePartByID(7);
	 m_pArmRight = m_Bone.GetBonePartByID(5);
	 

	m_SecondaryWeaponCounter.SetLimit(1.2f);	

	//m_MaxLife = m_Life = 20;

}

void	FIGBossBeast::Tick_Attack(float dt)
{
	//return;
	if(!m_IsAlive)
		return;
	FIGEnemyBoss::Tick_Attack(dt);
	
	if(FIGBossAttackMoveManager::Instance().ShouldDisableBoneMovement() == false)
	{

		if(m_pArmLeft)
			m_pArmLeft->AimToPlayer(m_Pos,15.0f *  dt);

		if(m_pArmRight)
			m_pArmRight->AimToPlayer(m_Pos,15.0f *  dt);
	}
	
}


void		FIGBossBeast::OnShootStyle1()
{
	//return;
	FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(2),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180.0f,		// degree
											0,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

	FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(3),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180.0f ,		// degree
											0,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									); 


}

void		FIGBossBeast::OnShootStyle2()
{
	
	//return;
	math::Vec2 PFromRotation = FigFunctions::RotateAroundPos(	m_pArmRight->GetPosBackup(),
																m_Bone.GetPosByWayPoint(0),
																m_pArmRight->GetRotation());
	
	FIGEnemyBulletMaster::Instance().Shoot(
											this,
											PFromRotation,
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_GREEN,
											FIGBullet::SHOOT_STYLES_SINGLE,
											m_pArmRight->GetRotation() + 180.0f,		// degree
											0,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);	

	PFromRotation = FigFunctions::RotateAroundPos(	m_pArmLeft->GetPosBackup(),
													m_Bone.GetPosByWayPoint(1),
													m_pArmLeft->GetRotation());
	

	FIGEnemyBulletMaster::Instance().Shoot(
											this,
											PFromRotation,
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_GREEN,
											FIGBullet::SHOOT_STYLES_SINGLE,
											m_pArmLeft->GetRotation() + 180.0f ,		// degree
											0,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									); 


}


void		FIGBossBeast::OnSecondaryWeaponShoot()
{
	//return;

	//sometimes don't shoot / rest
	if(num::RAND32::Instance().RandInt(0,3)==1)
		return;

	FIGEnemyBulletMaster::BULLET_TYPES BulletType = FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER;
	if(num::RAND32::Instance().RandInt(0,1)==1)
	{
		BulletType =  FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_TRIPPLELAYER;
	}

	FIGBullet::SHOOT_STYLES ShootStyle = FIGBullet::SHOOT_STYLES_SHAPE_TRIANGLE;
	if(num::RAND32::Instance().RandInt(0,1)==1)
	{
		ShootStyle = FIGBullet::SHOOT_STYLES_SHAPE_CIRCLE;
	}
	
	int C = num::RAND32::Instance().RandInt(8,10);
	float Delay = 0.0f;
	for(int i = 0; i < C; i++)
	{
		Delay +=  (1.0f/((float)C)); 
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(4),
											BulletType,
											ShootStyle,
											(360.0f / (float)C) * i ,		// degree
											Delay,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);

		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(5),
											BulletType,
											ShootStyle,
											(360.0f / (float)C) * i ,		// degree
											Delay,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);
	}
}









	